<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>计算属性的setter和getter</title>
    <script src="./vue.js"></script>
</head>

<body>
    <div id='app'>
        {{fullName}}
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                nameA: '小林',
                nameB: '小明1',
            },
            //1.计算属性 值没变使用缓存（优先使用）
            computed: {
                fullName: {
                    get: function () {
                        console.log('计算一次');
                        return this.nameA + " " + this.nameB
                    },
                    set: function (value) {
                        var arr = value.split(" ");
                        this.nameA = arr[0];
                        this.nameB = arr[1];
                    }

                }
            }
        })
    </script>
</body>

</html>